home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: HELP: no mapping at the fault address
- Date: Sun, 07 Apr 96 19:17:55 GMT
- Organization: none
- Message-ID: <828904675snz@genesis.demon.co.uk>
- References: <opybocswab.fsf@sweetbay.will.uiuc.edu> <4k3qn8$1gk6@msunews.cl.msu.edu> <828829661snz@genesis.demon.co.uk> <828843649snz@tsys.demon.co.uk>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <828843649snz@tsys.demon.co.uk>
- tomw@tsys.demon.co.uk "Tom Wheeley" writes:
-
- >In article <828829661snz@genesis.demon.co.uk>
- > fred@genesis.demon.co.uk "Lawrence Kirby" writes:
- >
- >> In article <4k3qn8$1gk6@msunews.cl.msu.edu>
- >> jliu@perm.fw.msu.edu "Jianguo Liu" writes:
- >>
- ...
- >> >The current line is
- >> >
- >> >new_ptr=(strucut tree *) malloc(sizeof(struct tree));
- >>
- >> Did you include stdlib.h? You must ensure that all functions that don't
- >> return int or are variadic are declared (it is best that all functions are
- >> declared). If that isn't the problem your program probably corrupted the
- >
- >Would I be right in saying that if he had omitted the cast for the return
- >value of malloc() then this error would have arisen as a warning in an
- >ISO compiler? With (void *) being `equivalent' to any old pointer etc.
-
- Without a declaration in scope the compiler must assume that malloc() returns
- int. Trying to convert implicitly from an int to a pointer (other than
- a constant expression with value 0) violates a constraint so, yes, the
- compiler must diagnose. void * isn't equilalent to other pointer types but
- may be converted implicitly to and from other pointer types (except pointers
- to functions) so the cast here can be omitted and probably should be since
- its main effect is to cover up a potential bug.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-